﻿using System;

namespace Nardax.Data
{
    public static class NullableExtensions
    {
        /// <summary>
        /// Returns the value of the source passed in as its value or DBNull when the nullable value is null.
        /// </summary>
        public static object ToValueOrDBNull<T>(this T? source) where T : struct
        {
            if (source.HasValue)
            {
                return source.Value;
            }

            return DBNull.Value;
        }
    }
}
